package org.jackysoft.struts2.core;

import java.util.Collection;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Namespace;
import org.jackysoft.entity.User;
import org.jackysoft.service.UserService;
import org.jackysoft.struts2.UtilsCRUDAction;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;

@Namespace("/admin/preuser")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
public class PreUserAction extends UtilsCRUDAction<User> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3287740122224187957L;
    private UserService service;
    private User bean;
    private Collection<User> beans;
   
    
    public String checkin() throws Exception{
    	resultMap.put("hasin", service.exists(bean.getUsername()));
    	return MAPDATA;
    }
    
    public String passall() throws Exception{
    	service.pass(beans);
    	return "passall";
    }
    
    public String datalist() throws Exception{
    	searchMap.clear();
    	searchMap.put("unpassed", Boolean.FALSE);
    	getJson();
    	return JQGRID;
    }
    
  
   
    
    
	public UserService getService() {
		return service;
	}
	
	@Resource
	public void setService(UserService service) {
		this.service = service;
		this.setDataProvider(service);
	}


	public User getBean() {
		return bean;
	}


	public void setBean(User bean) {
		this.bean = bean;
	}


	public Collection<User> getBeans() {
		return beans;
	}


	public void setBeans(Collection<User> beans) {
		this.beans = beans;
	}

	
	
}
